In processes of video transmission or storage, in order to reduce the amount of data to be transmitted or stored, it is usually required to compress and encode the original video data. The motion complexity, dynamic texture, masking, illumination variation or the like would be different per frame, and thus the amount of data of the compressed frame will change, and the bit rate of video transmission in unit time will fluctuate. In an actual video transmission or storage application, due to limitations on the bandwidth and storage space, it is often required to limit the maximum, average, and the like of the bit rate. The process of controlling bit rate is a process of controlling some coding parameters of an encoder such that the bit rate generated by the encoder is as expected. The relationship between the bit rate controller and the encoder is as shown in FIG. 1. An encoder 103 encodes an input video frame 101 based on the coding parameters output by a bit rate controller 102, feeds back the status of the encoded bit stream to the bit rate controller 102, and outputs a video bit stream.
In practical applications, there are usually two bit rate control modes: VBR (Variable Bit Rate) and CBR (Constant Bit Rate). The VBR sets the image quality value and the upper limit of the bit rate, and stably maintains the image quality at the set value without exceeding the upper limit of the bit rate. This mode is suitable for application scenarios of local storage. The CBR maintains the instantaneous output bit rate at a set bit rate value, which is suitable for application scenarios where the channel bandwidth is substantially constant.
When a coding device adopts the VBR mode, since it is difficult to estimate the fluctuation of the bit rate, the upper limit of the bit rate of the VBR is generally used to calculate the storage space, which may result in a large estimated capacity of the storage device and thus wasting storage resources. When a coding device adopts the CBR mode, the target bit rate value of the CBR can be used to accurately estimate the storage space required by a monitoring system. However, the CBR algorithm performs encoding in both of a simple scenarios and a complex scenarios by using a same target bit rate; when encoding in a complex scenarios, in order to prevent overflow of storage space, a greater bit rate cannot be used for encoding, which results in a degradation in image quality. Therefore, it is difficult to obtain a bit stream with the best definition and effect through the above two commonly used bit rate control modes with the maximum efficiency in a certain capacity of the storage space.
For the problem that the estimated capacity of the storage apparatus is too large and the storage resources are wasted in the VBR mode, in the prior art, it is proposed to configure a smaller storage space for the coding device according to service requirements, monitor the remaining storage space and storage time in real time on the basis of obtaining a fixed-quality video encoded bit stream using the VBR, and ensure that the actual encoding bit stream meets the storage space requirements by using a bit rate controlling strategy such as frameskip, lowing quantization parameters or the like. However, this solution can only ensure that the actual encoding size is not greater than a preset storage space, which may cause excessive space remaining on the hard disk during actual use.
For the problem of unstable image quality in CBR mode, in the prior art, a buffer adaptive bit stream control method is proposed. This method is to adjust, based on the CBR, the two parameters of the target equilibrium point of the virtual buffer and the buffer adjustment strength through the analysis of the image complexity information over a period of time to cope with the frameskip and unstable image quality due to the image becoming complex. However, in this solution, the adjustment margin of the target balance point is too small, which can only cope with a short-term image complexity. If the scene becomes complicated for a long time, it is difficult to ensure that the bit rate during an idle period can be distributed to the busy period, thereby resulting in that there is not enough storage space to guarantee image quality during the busy period.
In summary, the bit rate control methods in the prior art cannot allocate storage space reasonably under the condition that the image satisfies a certain quality.